<?php


namespace app\home\model\feedback;


use app\home\model\BaseModel;
use traits\model\SoftDelete;

class Feedback extends BaseModel
{
    use SoftDelete;
    protected $autoWriteTimestamp='datetime';
    protected $append = ['handle_time'];
    protected $hidden=['delete_time','type','update_time','contact'];


    /**
     * @param $did
     * @param $offset
     * @param $limit
     * @return false
     */
    public function getList($did,$offset,$limit){
        $res =  self::where('dealer_id',$did)->order('update_time','desc')->limit($offset,$limit)->select();
        return $res;
    }

    /**
     * @param $val
     * @param $data
     * @return |null
     */
    protected function getHandleTimeAttr($val,$data)
    {
        $val = $data['status'] == 1 ? $data['update_time'] : null;
        return $val;
    }

    /**
     * @param $val
     * @param $data
     * @return array
     */
    protected function getImagesAttr($val,$data)
    {
        $val = !empty($data['images']) ? explode(',',$data['images']) : [];
        return $val;
    }

}